//
// Created by GYC on 2021/6/1.
//

#include "../../common.h"

class Solution {

public:
    vector<bool> canEat(vector<int> &candiesCount, vector<vector<int>> &queries) {
        vector<long long> note(candiesCount.size());
        note[0] = 0;
        for (int i = 1; i < candiesCount.size(); ++i) {
            note[i] = note[i - 1] + candiesCount[i - 1];
        }

        vector<bool> res{};
        for (auto & query : queries) {
            long minDay = query[1] + 1;
            long maxDay = ((long) query[1] + 1) * query[2];

            long minTarget = note[query[0]] + 1;
            long maxTarget = minTarget + candiesCount[query[0]] - 1;

            res.push_back(!(maxDay < minTarget || minDay > maxTarget));
        }
        return res;
    }
};

int main() {
    vector<int> candiesCount{7, 4, 5, 3, 8};
    vector<vector<int>> queries{{0, 2,  2},
                                {4, 2,  4},
                                {2, 13, 1000000000}};

    Solution().canEat(candiesCount, queries);
}